#!/usr/bin/env jruby
# -*- coding: us-ascii -*-

require 'test/unit'
dir = File.dirname(__FILE__)
require File.join(dir, '..', '..', 'lib', 'monkey', 'math')
require File.join(dir, '..', 'gibberish')
require File.join(dir, '..', 'handy4testing')

########################################

class TestMathA < Test::Unit::TestCase
  def test_should_be_float
    assert_kind_of Float, Math::A
  end
  
  def test_should_be_greater_than_zero_less_than_one
    assert Math::A > 0 and Math::A < 1
  end
end

########################################

class TestMathH < Test::Unit::TestCase
  include Gibberish
  include Handy4Testing
  
  def test_should_be_integer
    word = wordn(30).hash
    result = Math.h(word, rand(1000))
    assert_kind_of Integer, result
  end
  
  def test_should_be_at_least_zero_less_than_m
    stress(10) do
      word = wordn(30).hash
      m = rand(1000)
      result = Math.h(word, m)
      assert result >= 0 and result < m
    end
  end
end
